package com.net.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@Entity
public class Commodity {
	private int id;
	private String commodity_name;
	private String short_name;
	private String product_area;
	private String unit;
	private String lot_number;
	private String description;
	private String scale;
	private String package_info;
	private String permission_number;
	private int stock_count;
	private float current_price;
	private int min_store;
	private int max_store;
	private List<Provider> providers;
	private Category category;
	
	public Commodity(){
		
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCommodity_name() {
		return commodity_name;
	}

	public void setCommodity_name(String commodity_name) {
		this.commodity_name = commodity_name;
	}

	public String getShort_name() {
		return short_name;
	}

	public void setShort_name(String short_name) {
		this.short_name = short_name;
	}

	public String getProduct_area() {
		return product_area;
	}

	public void setProduct_area(String product_area) {
		this.product_area = product_area;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public String getLot_number() {
		return lot_number;
	}

	public void setLot_number(String lot_number) {
		this.lot_number = lot_number;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getScale() {
		return scale;
	}

	public void setScale(String scale) {
		this.scale = scale;
	}

	public String getPackage_info() {
		return package_info;
	}

	public void setPackage_info(String package_info) {
		this.package_info = package_info;
	}

	public String getPermission_number() {
		return permission_number;
	}

	public void setPermission_number(String permission_number) {
		this.permission_number = permission_number;
	}

	@ManyToOne(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
	@JoinColumn(name="category_id")
	public Category getCategory() {
		return category;
	}


	public void setCategory(Category category) {
		this.category = category;
	}
	@ManyToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
	@JoinTable(name="commodity_provider",
			joinColumns={@JoinColumn(name="commodity_id")},
			inverseJoinColumns={@JoinColumn(name="provider_id")})
	public List<Provider> getProviders() {
		return providers;
	}

	public void setProviders(List<Provider> providers) {
		this.providers = providers;
	}

	public int getMin_store() {
		return min_store;
	}

	public void setMin_store(int min_store) {
		this.min_store = min_store;
	}

	public int getMax_store() {
		return max_store;
	}

	public void setMax_store(int max_store) {
		this.max_store = max_store;
	}

	public float getCurrent_price() {
		return current_price;
	}

	public void setCurrent_price(float current_price) {
		this.current_price = current_price;
	}

	public int getStock_count() {
		return stock_count;
	}

	public void setStock_count(int stock_count) {
		this.stock_count = stock_count;
	}
	
}
